﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrganizacijaPodrobnosti.aspx.cs"
    Inherits="Sio.Mdm.Web.Instalacija.OrganizacijaPodrobnosti" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Podrobnosti organizacije</title>
    <ext:XScript ID="XScript1" runat="server">

        <script type="text/javascript">
        var spoliRenderer = function(value) {
            var r = StoreSpoli.getById(value);
            if (Ext.isEmpty(r)) { return ""; }
            return r.data.Naziv;
        };

    var dodajZapis = function () {
      var grid = #{GridAdminSeznam};
      grid.getRowEditor().stopEditing();    
      grid.insertRecord(0, {
          IdmStevilka: -99,
			    Naziv   : "",
      });
      
      grid.getView().refresh();
      grid.getSelectionModel().selectRow(0);
      grid.getRowEditor().startEditing(0);
    }
    
    var dodajRazred = function () {
      var grid = #{GridRazredSeznam};
      grid.getRowEditor().stopEditing();    
      grid.insertRecord(0, {
          RazredId: -99,
		  Oznaka  : ""
      });
      grid.getView().refresh();
      grid.getSelectionModel().selectRow(0);
      grid.getRowEditor().startEditing(0);
    }    
        </script>

    </ext:XScript>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager runat="server" />
    <ext:Store runat="server" ID="StoreObcine">
        <reader>
            <ext:JsonReader IDProperty="ObcinaId">
                <Fields>
                    <ext:RecordField Name="ObcinaId" Type="Int" />
                    <ext:RecordField Name="Naziv" Type="String" />
                </Fields>
            </ext:JsonReader>
        </reader>
    </ext:Store>
    <ext:Store runat="server" ID="StoreSolskaLeta">
        <reader>
            <ext:JsonReader IDProperty="LetoId">
                <Fields>
                    <ext:RecordField Name="LetoId" Type="Int" />
                    <ext:RecordField Name="Naziv" Type="String" />
                </Fields>
            </ext:JsonReader>
        </reader>
    </ext:Store>
    <ext:Store ID="StoreZdravstveniDom" runat="server">
        <reader>
            <ext:JsonReader IDProperty="ZdravstveniDomId">
                <Fields>
                    <ext:RecordField Name="ZdravstveniDomId" Type="Int" />
                    <ext:RecordField Name="Naziv" Type="String" />
                </Fields>
            </ext:JsonReader>
        </reader>
    </ext:Store>
    <ext:Store ID="StoreTipOrganizacije" runat="server">
        <reader>
            <ext:JsonReader IDProperty="TipOrganizacijeId">
                <Fields>
                    <ext:RecordField Name="TipOrganizacijeId" Type="Int" />
                    <ext:RecordField Name="Naziv" Type="String" />
                </Fields>
            </ext:JsonReader>
        </reader>
    </ext:Store>
    <ext:Store ID="StoreKategorijeZavodov" runat="server">
        <reader>
            <ext:JsonReader IDProperty="KategorijeZavodovId">
                <Fields>
                    <ext:RecordField Name="KategorijeZavodovId" Type="Int" />
                    <ext:RecordField Name="Naziv" Type="String" />
                </Fields>
            </ext:JsonReader>
        </reader>
    </ext:Store>
    <ext:Store ID="StoreSpoli" runat="server">
        <reader>
            <ext:ArrayReader IDProperty="SpolID">
                <Fields>
                    <ext:RecordField Name="SpolID" Type="Int" />
                    <ext:RecordField Name="Naziv" Type="String" />
                </Fields>
            </ext:ArrayReader>
        </reader>
    </ext:Store>
    <ext:Viewport runat="server" Layout="Fit">
        <items>
            <ext:Panel ID="Panel4" runat="server" Border="false" Layout="fit">
                <Items>
                    <ext:TabPanel runat="server" ID="OrganizacijaPanel" Border="false" LayoutOnTabChange="true">
                        <Items>
                            <ext:FormPanel ID="FormPanelPodrobnosti" Title="Osnovni podatki" runat="server" Padding="0"
                                LabelAlign="Top">
                                <TopBar>
                                    <ext:Toolbar ID="Toolbar1" runat="server">
                                        <Items>
                                            <ext:Button ID="btnShrani" runat="server" Text="Shrani" Icon="Disk">
                                                <Listeners>
                                                    <Click Handler="Ext.net.DirectMethods.ShraniPodrobnostiOrganizacije();"/>
                                                </Listeners>
                                            </ext:Button>
                                            <ext:Button ID="btnPreklici" runat="server" Text="Prekliči" Icon="Decline">
                                                <Listeners>
                                                    <Click Handler="Ext.net.DirectMethods.NaloziPodatkeOOrganizaciji();"/>
                                                </Listeners>
                                            </ext:Button>
                                        </Items>
                                    </ext:Toolbar>
                                </TopBar>
                                <Items>
                                    <ext:Panel ID="Panel1" runat="server" Padding="6" Width="600" Border="false">
                                        <Items>
                                            <ext:Container ID="Container4" runat="server" Layout="Column" Height="40">
                                                <Items>
                                                    <ext:Container ID="Container5" runat="server" LabelAlign="Top" Layout="Form" ColumnWidth="1">
                                                        <Items>
                                                            <ext:TextField ID="fldNaziv" DataIndex="Naziv" runat="server" FieldLabel="Naziv"
                                                                AllowBlank="false" MinLength="2" AnchorHorizontal="80%" />
                                                            <ext:Checkbox ID="fldAktivno" DataIndex="Aktivno" runat="server" FieldLabel="Aktivno"
                                                                AllowBlank="false" AnchorHorizontal="20%" />
                                                        </Items>
                                                    </ext:Container>
                                                </Items>
                                            </ext:Container>
                                        </Items>
                                    </ext:Panel>
                                    <ext:Panel ID="Panel3" runat="server" Padding="6" Width="600" Border="false">
                                        <Items>
                                            <ext:Container ID="Container1" runat="server" Layout="Column" Height="90">
                                                <Items>
                                                    <ext:Container ID="Container2" runat="server" LabelAlign="Top" Layout="Form" ColumnWidth=".5">
                                                        <Items>
                                                            <ext:ComboBox ID="cbTipOrganizacije" runat="server" StoreID="StoreTipOrganizacije"
                                                                Editable="false" DisplayField="Naziv" ValueField="TipOrganizacijeId" EmptyText="Izberi..." Mode="Local" ForceSelection="true"  
                                                                SelectOnFocus="true" 
                                                                FieldLabel="Tip Organizacije" BlankText="Izberi tip organizacije ..." AnchorHorizontal="95%">
                                                            </ext:ComboBox>
                                                                                                                
                                                            <ext:ComboBox ID="cbKategorijeZavodov" runat="server" StoreID="StoreKategorijeZavodov"
                                                                Editable="false" DisplayField="Naziv" ValueField="KategorijeZavodovID" EmptyText="Izberi..."
                                                                FieldLabel="Kategorija zavoda" BlankText="Izberi kategorijo zavoda ..." AnchorHorizontal="95%">
                                                            </ext:ComboBox>
                                                        </Items>
                                                    </ext:Container>
                                                    <ext:Container ID="Container3" runat="server" LabelAlign="Top" Layout="Form" ColumnWidth=".5">
                                                        <Items>
                                                            <ext:ComboBox ID="cbObcine" runat="server" StoreID="StoreObcine" Editable="false"
                                                                LabelAlign="Top" FieldLabel="Občina" DisplayField="Naziv" ValueField="ObcinaId"
                                                                TypeAhead="true" AnchorHorizontal="98%" Mode="Local" ForceSelection="true" EmptyText="Izberi občino..."
                                                                Resizable="false" SelectOnFocus="true" AutoHeight="true" />
                                                            <ext:ComboBox ID="cbZdravstveniDom" runat="server" StoreID="StoreZdravstveniDom"
                                                                Editable="false" DisplayField="Naziv" ValueField="ZdravstveniDomID" EmptyText="Izberi..."
                                                                FieldLabel="Zdravstveni dom" AnchorHorizontal="98%">
                                                            </ext:ComboBox>
                                                        </Items>
                                                    </ext:Container>
                                                </Items>
                                            </ext:Container>
                                        </Items>
                                    </ext:Panel>
                                    <ext:Panel ID="Panel2" runat="server" Padding="6" Width="600" Border="false">
                                        <Items>
                                            <ext:Container ID="Container6" runat="server" Layout="Column" Height="40">
                                                <Items>
                                                    <ext:Container ID="Container7" runat="server" LabelAlign="Top" Layout="Form" ColumnWidth="1">
                                                        <Items>
                                                            <ext:NumberField ID="fldDavcna" DataIndex="davcna" runat="server" FieldLabel="Davčna"
                                                                AllowBlank="false" MinLength="8" MaxLength="8" AnchorHorizontal="15%" />
                                                        </Items>
                                                    </ext:Container>
                                                </Items>
                                            </ext:Container>
                                        </Items>
                                    </ext:Panel>
                                </Items>
                            </ext:FormPanel>
                            <ext:FormPanel Title="Razredi" runat="server" Padding="0" LabelAlign="Top">
                            <items>
                            
                            <ext:BorderLayout Title="Razredi" runat="server" Padding="0" >
                            <North>
                                    <ext:Panel runat="server" ID="solskoLetoPanel" Border="false" Layout="Form" Height="70" Padding="6" >
                                        <Items>
                                                        <ext:ComboBox ID="ComboLeta" runat="server" StoreID="StoreSolskaLeta" Editable="false"
                                                            DisplayField="Naziv" ValueField="LetoId" TypeAhead="true" Mode="Local" ForceSelection="true"
                                                            EmptyText="Izberi šolsko leto..." Resizable="false" SelectOnFocus="true" AutoHeight="true"
                                                            Width="150" FieldLabel="Šolsko leto">
                                                            <Listeners>
                                                                 <Select Handler="#{StoreRazrediSeznam}.reload();" />
                                                            </Listeners>
                                                        </ext:ComboBox>
                                        </Items>
                                    </ext:Panel>                             
                            </North>
                            <Center>
                                    <sio:GridPanel ID="GridRazredSeznam" runat="server" StripeRows="true" TrackMouseOver="true" Layout="Fit">
                                        <Plugins>
                                            <ext:RowEditor runat="server" SaveText="Shrani" CancelText="Prekliči" ClicksToEdit="2">
                                                <DirectEvents>
                                                    <AfterEdit OnEvent="UrediRazrede">
                                                        <ExtraParams>
                                                            <ext:Parameter Mode="Raw" Name="data" Value="r.data" />
                                                        </ExtraParams>
                                                    </AfterEdit>
                                                </DirectEvents>
                                            </ext:RowEditor>
                                            <ext:GridFilters Irunat="server">
                                                <Filters>
                                                    <ext:NumericFilter DataIndex="RazredId" />
                                                    <ext:NumericFilter DataIndex="Razred" />
                                                    <ext:StringFilter DataIndex="Paralelka" />
                                                    <ext:StringFilter DataIndex="Oznaka" />
                                                </Filters>
                                            </ext:GridFilters>
                                        </Plugins>
                                        <Store>
                                            <ext:Store ID="StoreRazrediSeznam" runat="server" OnRefreshData="StoreRazrediRefresh">
                                                <SortInfo Field="RazredId" />
                                                <Reader>
                                                    <ext:JsonReader IDProperty="RazredId">
                                                        <Fields>
                                                            <ext:RecordField Name="RazredId" Type="Int" />
                                                            <ext:RecordField Name="Razred" Type="Int" />
                                                            <ext:RecordField Name="Paralelka" Type="String" />
                                                            <ext:RecordField Name="Oznaka" Type="String" />
                                                        </Fields>
                                                    </ext:JsonReader>
                                                </Reader>
                                            </ext:Store>
                                        </Store>
                                        <ColumnModel ID="ColumnModelRazredi" runat="server">
                                            <Columns>
                                                <ext:RowNumbererColumn />
                                                <ext:Column ColumnID="RazredId" Hidden="true" Hideable="false" DataIndex="RazredId" />
                                                <ext:Column ColumnID="Razred" Header="Razred" DataIndex="Razred"
                                                    Width="80">
                                                    <Editor>
                                                        <ext:NumberField runat="server" AllowBlank="false" MinLength="1" MaxLength="1" MinLengthText="Vpišite številko razreda"
                                                            BlankText="Vpišite številko razreda" />
                                                    </Editor>
                                                </ext:Column>
                                                <ext:Column Header="Paralelka" DataIndex="Paralelka" Width="80">
                                                    <Editor>
                                                        <ext:TextField runat="server" AllowBlank="false" MinLength="1" MaxLength="3"  MinLengthText="Vpišite naziv paralelke"
                                                            BlankText="Vpišite naziv paralelke" />
                                                    </Editor>
                                                </ext:Column>
                                                <ext:Column Header="Oznaka" DataIndex="Oznaka" Width="150">
                                                    <Editor>
                                                        <ext:TextField runat="server" AllowBlank="true"
                                                            BlankText="Vpišite oznako razreda" />
                                                    </Editor>
                                                </ext:Column>                                                
                                            </Columns>
                                        </ColumnModel>
                                        <SelectionModel>
                                            <ext:CheckboxSelectionModel runat="server" />
                                        </SelectionModel>
                                        <TopBar>
                                            <ext:Toolbar runat="server" Width="500">
                                                <Items>
                                                    <sio:Button runat="server" Text="Dodaj" Icon="Add">
                                                        <Listeners>
                                                            <Click Fn="dodajRazred" />
                                                        </Listeners>
                                                    </sio:Button>
                                                    <sio:Button runat="server" Text="Briši" Icon="Delete">
                                                        <DirectEvents>
                                                            <Click OnEvent="OdstraniRazrede" After="#{StoreRazrediSeznam}.reload();">
                                                                <Confirmation ConfirmRequest="true" Message="Izbrišem izbrane razrede?" />
                                                                <ExtraParams>
                                                                    <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridRazredSeznam}.getRowsValues({selectedOnly:true}))" />
                                                                </ExtraParams>
                                                            </Click>
                                                        </DirectEvents>
                                                    </sio:Button>
                                                </Items>
                                            </ext:Toolbar>
                                        </TopBar>
                                    </sio:GridPanel>
                            </Center>
                            </ext:BorderLayout>
                            </items>
                            </ext:FormPanel>
                            <sio:GridPanel ID="GridAdminSeznam" Title="Administratorji" runat="server" StripeRows="true"
                                TrackMouseOver="true" LabelAlign="Top">
                                <Plugins>
                                    <ext:GridFilters ID="GridFilters1" runat="server">
                                        <Filters>
                                            <ext:StringFilter DataIndex="Ime" />
                                            <ext:StringFilter DataIndex="Priimek" />
                                            <ext:NumericFilter DataIndex="IdmStevilka" />
                                        </Filters>
                                    </ext:GridFilters>
                                </Plugins>
                                <Store>
                                    <ext:Store ID="StoreAdminSeznam" runat="server">
                                        <SortInfo Field="Priimek" />
                                        <Reader>
                                            <ext:JsonReader IDProperty="IdmStevilka">
                                                <Fields>
                                                    <ext:RecordField Name="IdmStevilka" Type="Int" />
                                                    <ext:RecordField Name="VlogaId" Type="Int" />
                                                    <ext:RecordField Name="Ime" Type="String" />
                                                    <ext:RecordField Name="Priimek" Type="String" />
                                                    <ext:RecordField Name="UporabniskoIme" Type="String" />
                                                    <ext:RecordField Name="Email" Type="String" />
                                                    <ext:RecordField Name="Spol" Type="Int" />
                                                </Fields>
                                            </ext:JsonReader>
                                        </Reader>
                                    </ext:Store>
                                </Store>
                                <ColumnModel ID="ColumnModel1" runat="server">
                                    <Columns>
                                        <ext:RowNumbererColumn />
                                        <ext:Column ColumnID="IdmStevilka" Hidden="true" Hideable="false" DataIndex="IdmStevilka">
                                        </ext:Column>
                                        <ext:Column ColumnID="VlogaId" Hidden="true" Hideable="false" DataIndex="VlogaId">
                                        </ext:Column>
                                        <ext:Column ColumnID="Ime" Header="Ime" DataIndex="Ime">
                                            <Editor>
                                                <ext:TextField runat="server" AllowBlank="false" MinLength="2" MinLengthText="Vpišite ime"
                                                    BlankText="Vpišite ime" />
                                            </Editor>
                                        </ext:Column>
                                        <ext:Column Header="Priimek" DataIndex="Priimek">
                                            <Editor>
                                                <ext:TextField runat="server" AllowBlank="false" MinLength="2" MinLengthText="Vpišite priimek"
                                                    BlankText="Vpišite priimek" />
                                            </Editor>
                                        </ext:Column>
                                        <ext:Column Header="Uporabniško ime" DataIndex="UporabniskoIme">
                                            <Editor>
                                                <ext:TextField runat="server" AllowBlank="false" MinLength="2" MinLengthText="Vpišite uporabniško ime"
                                                    BlankText="Vpišite uporabniško ime" />
                                            </Editor>
                                        </ext:Column>
                                        <ext:Column Header="Email" DataIndex="Email">
                                            <Editor>
                                                <ext:TextField runat="server" AllowBlank="false" MinLength="2" MinLengthText="Vpišite e-mail"
                                                    BlankText="Vpišite email" />
                                            </Editor>
                                        </ext:Column>
                                        <ext:Column Header="Spol" DataIndex="Spol">
                                            <Renderer Fn="spoliRenderer" />
                                            <Editor>
                                                <ext:ComboBox ID="cbSpoli" runat="server" TypeAhead="true" SelectOnFocus="true" Editable="true"
                                                    Mode="Local" ForceSelection="true" StoreID="StoreSpoli" ValueField="SpolID" DisplayField="Naziv" />
                                            </Editor>
                                        </ext:Column>
                                        <ext:CommandColumn Width="70">
                                            <Commands>
                                                <ext:GridCommand Icon="NoteEdit" CommandName="Uredi">
                                                    <ToolTip Text="Uredi" />
                                                </ext:GridCommand>
                                            </Commands>
                                        </ext:CommandColumn>
                                    </Columns>
                                </ColumnModel>
                                <Listeners>
                                    <Command Handler="openTab('../Uporabnik/Akter.aspx', 'Učeči '+record.data.Ime+' '+record.data.Priimek, {idm: record.id }, 'akter'+record.id);" />
                                </Listeners>
                                <SelectionModel>
                                    <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" />
                                </SelectionModel>
                            </sio:GridPanel>
                        </Items>
                    </ext:TabPanel>
                </Items>
            </ext:Panel>
        </items>
    </ext:Viewport>
    </form>
</body>
</html>
